package o;

import android.os.Handler;
import android.os.Handler.Callback;
import android.os.Looper;
import android.os.Message;
import java.lang.ref.WeakReference;

public class asr {
    private static asr ˋ;
    private final Handler ˊ = new Handler(Looper.getMainLooper(), new Callback(this) {
        final /* synthetic */ asr ॱ;

        {
            this.ॱ = r1;
        }

        public boolean handleMessage(Message message) {
            switch (message.what) {
                case 0:
                    this.ॱ.ॱ((c) message.obj);
                    return true;
                default:
                    return false;
            }
        }
    });
    private c ˎ;
    private final Object ˏ = new Object();
    private c ॱ;

    public interface a {
        void ˊ();

        void ˏ(int i);
    }

    static class c {
        boolean ˋ;
        final WeakReference<a> ˏ;
        int ॱ;

        boolean ˊ(a aVar) {
            return aVar != null && this.ˏ.get() == aVar;
        }
    }

    public static asr ॱ() {
        if (ˋ == null) {
            ˋ = new asr();
        }
        return ˋ;
    }

    private asr() {
    }

    public void ˊ(a aVar, int i) {
        synchronized (this.ˏ) {
            if (ʽ(aVar)) {
                ˎ(this.ˎ, i);
            } else if (ॱॱ(aVar)) {
                ˎ(this.ॱ, i);
            }
        }
    }

    public void ˊ(a aVar) {
        synchronized (this.ˏ) {
            if (ʽ(aVar)) {
                this.ˎ = null;
                if (this.ॱ != null) {
                    ˋ();
                }
            }
        }
    }

    public void ˋ(a aVar) {
        synchronized (this.ˏ) {
            if (ʽ(aVar)) {
                ˏ(this.ˎ);
            }
        }
    }

    public void ˏ(a aVar) {
        synchronized (this.ˏ) {
            if (ʽ(aVar) && !this.ˎ.ˋ) {
                this.ˎ.ˋ = true;
                this.ˊ.removeCallbacksAndMessages(this.ˎ);
            }
        }
    }

    public void ॱ(a aVar) {
        synchronized (this.ˏ) {
            if (ʽ(aVar) && this.ˎ.ˋ) {
                this.ˎ.ˋ = false;
                ˏ(this.ˎ);
            }
        }
    }

    public boolean ˎ(a aVar) {
        boolean z;
        synchronized (this.ˏ) {
            z = ʽ(aVar) || ॱॱ(aVar);
        }
        return z;
    }

    private void ˋ() {
        if (this.ॱ != null) {
            this.ˎ = this.ॱ;
            this.ॱ = null;
            a aVar = (a) this.ˎ.ˏ.get();
            if (aVar != null) {
                aVar.ˊ();
            } else {
                this.ˎ = null;
            }
        }
    }

    private boolean ˎ(c cVar, int i) {
        a aVar = (a) cVar.ˏ.get();
        if (aVar == null) {
            return false;
        }
        this.ˊ.removeCallbacksAndMessages(cVar);
        aVar.ˏ(i);
        return true;
    }

    private boolean ʽ(a aVar) {
        return this.ˎ != null && this.ˎ.ˊ(aVar);
    }

    private boolean ॱॱ(a aVar) {
        return this.ॱ != null && this.ॱ.ˊ(aVar);
    }

    private void ˏ(c cVar) {
        if (cVar.ॱ != -2) {
            int i = 2750;
            if (cVar.ॱ > 0) {
                i = cVar.ॱ;
            } else if (cVar.ॱ == -1) {
                i = 1500;
            }
            this.ˊ.removeCallbacksAndMessages(cVar);
            this.ˊ.sendMessageDelayed(Message.obtain(this.ˊ, 0, cVar), (long) i);
        }
    }

    void ॱ(c cVar) {
        synchronized (this.ˏ) {
            if (this.ˎ == cVar || this.ॱ == cVar) {
                ˎ(cVar, 2);
            }
        }
    }
}
